﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using ESRI.ArcGIS.Display;

namespace EAGL.Display.Rendering
{
    public struct ValueRenderingMapRow
    {
        public object value;
        public ISymbol symbol;
    }
    
    public  class ValueRenderingMap
    {
    #region ======================== PROTECETD ========================

        protected Hashtable mapping;

    #endregion

    
    #region ======================== PUBLIC ===========================

        public ValueRenderingMap()
        {
            mapping = new Hashtable();
        }
        
        public void Add(object value)
        {
            mapping.Add(value, null);
        }


        public void Add(object value, ISymbol symbol)
        {
            //if (value == null || symbol == null)
            //{
            //    throw new Exception("ValueRenderingMap can't accept null values.");
            //}
            
            mapping.Add(value, symbol);
        }
        
        
        public void Add(object[] values)
        {
            foreach (object o in values)
            {
                mapping.Add(values, null);
            }
        }


        public void Delete(object value)
        {
            mapping.Remove(value);
        }
        
        public void Clear()
        {
            mapping.Clear();
        }

        
        public ISymbol GetSymbol(object value)
        {
            ISymbol sym;
            sym = mapping[value] as ISymbol;
            return sym;
            
        }

        public List<ValueRenderingMapRow> List
        {
            get
            { 
                List<ValueRenderingMapRow> l = new List<ValueRenderingMapRow>();
                ValueRenderingMapRow row;
                foreach (object o in mapping.Keys)
                {
                    row.value = o;
                    row.symbol = mapping[o] as ISymbol;
                    l.Add(row);
                }
                return l;
            }
        }

        public int Count
        {
            get { return mapping.Count; }
        }


    #endregion

        
        
    }
}
